package com.sky.mapper;

import com.sky.entity.Dish;
import com.sky.entity.SetmealDish;
import com.sky.vo.DishItemVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface SetMealDishMapper {
    void insertBatch(List<SetmealDish> setmealDishes);

    /**
     * 删除套餐关联的套餐菜品表
     * @param setmealIds
     */
    void deleteBatchBysetdishId(List<Long> setmealIds);

    /**
     * 根据套餐id查询套餐菜品关系
     * @param setmealId
     * @return
     */
    @Select("select * from setmeal_dish where setmeal_id = #{setmealId}")
    List<SetmealDish> getByid(Long setmealId);

    List<Dish> getDishbySetId(Long id);

    /**
     * 根据套餐id来查找菜品的信息
     * @param id
     * @return
     */
    @Select("select d.name,s.copies,d.image,d.description from dish d left join setmeal_dish s on s.dish_id = d.id " +
            "where setmeal_id = #{id}")
    List<DishItemVO> getDishbySetmealId(Long id);
}
